package cn.com.shaom.learning.sb.session.example3;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
import org.springframework.session.web.http.CookieSerializer;
import org.springframework.session.web.http.DefaultCookieSerializer;

/**
 * ClassName: HttpSessionConfig
 * Description:
 * Date: 2018/1/10 19:50 【需求编号】
 *
 * @author Sam Sho
 * @version V1.0.0
 */
@Configuration
public class HttpSessionConfig {

    /**
     * 使用自定义CookieSerializer
     * @return
     */
    @Bean
    public CookieSerializer cookieSerializer() {
        DefaultCookieSerializer serializer = new DefaultCookieSerializer();
        serializer.setCookieName("JSESSIONID");
        serializer.setCookiePath("/");
        serializer.setDomainNamePattern("^.+?\\.(\\w+\\.[a-z]+)$");
        return serializer;
    }

}